package com.softeem.music.comm;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 统一返回结果类
 */

@Schema(description = "统一返回结果类")
@Accessors(chain = true)    //开启链式编程
@Data
public class R {
    //状态码
    @Schema(description = "状态码(200-ok,500-内部错误)")
    private Integer code;
    //附加文本信息
    @Schema(description = "附加文本信息")
    private String msg;
    //执行结果是否成功
    @Schema(description = "执行结果是否成功")
    private boolean success;
    //附加返回数据
    @Schema(description = "附加返回数据")
    private Object data;


    //数据总条数
    @Schema(description = "数据总条数")
    private Long count;


    //成功返回结果
    public static R success(){
        return new R().setSuccess(true).setCode(0).setMsg("操作成功");
    }

    public static R error(){
        return new R().setSuccess(false).setCode(500).setMsg("操作失败");
    }
}
